<?php

global $connect;

if (isset($_GET['id_mag']) AND $_GET['id_mag'] != NULL)
	$id_mag = $_GET['id_mag'];

if (isset($_GET['cmd_id']) AND $_GET['cmd_id'] != NULL)
{
	$cmd_id = $_GET['cmd_id'];
	$sql = "DELETE FROM `contenir` WHERE `NCOMMANDE` = '".$cmd_id."'";
	$res = mysql_query($sql) or die(mysql_error());
	$sql = "DELETE FROM `commandes` WHERE `NCOMMANDE` = '".$cmd_id."'";
	$res = mysql_query($sql) or die(mysql_error());
	echo "<div class='box_success'>Commande Supprim&eacute;e</div><br/>";
}	
	
//Recuperation des commandes pour ce magasin
$query = "SELECT * FROM `commandes` WHERE `NMAGASIN` = '".$id_mag."' AND livrer = 0;"; 
$result = mysql_query($query) or die(mysql_error());

//affichages  des commandes pour ce magasins
?>
<center>
<table frame="border" border="1" cellspacing="0" ><thead><tr>
	<th>Num&eacute;ro de commande</th>
	<th>Num&eacute;ro magasins</th>
	<th>Date de commande</th>
	<th>Livrer</th>
	<th>Action</th>
		</tr></thead>
<?php
while($data = mysql_fetch_array($result))
{
	echo "<tr>";
	echo "<td align='center' width='140px'><a href='index.php?page=magasins&action=check_liv&cmd_id=".$data['NCOMMANDE']."&id_mag=".$_GET['id_mag']."'>".$data['NCOMMANDE']."</a></td>";
	echo "<td align='center' width='140px'> ".$data['NMAGASIN']."</td>";
	echo "<td align='center' width='140px'>".$data['DATECMD']."</td>";
	echo "<td align='center' width='140px'>".$data['LIVRER']."</td>";
	echo "<td align='center' width='40px'><a href='index.php?page=magasins&action=livraison&cmd_id=".$data['NCOMMANDE']."&id_mag=".$_GET['id_mag']."'><img height='20px' width='20px' src='./img/Delete.png' /></a></td>";
	echo "</tr>";
}
echo "</table>";



?>

<center><h1><a href="index.php?page=magasins&show_mag_id=<?php echo $_GET['id_mag'] ?>"><img width="30px" height="30px" src="./img/jamembo-back.png" />Retour</a></h1></center>

</center>